00001 /* 00002 * Copyright (c) 2013 Battelle Memorial Institute 00003 * Licensed under modified BSD License. A copy of this license can be found 00004 * in the LICENSE file in the top level directory of this distribution. 00005 */ 00006 // ------------------------------------------------------------- 00007 /** 00008 * @file se_app_module.hpp 00009 * @author Yousu Chen, Bruce Palmer 00010 * @date 1/23/2015 00011 * @Last modified 1/23/2015 00012 * 00013 * @brief 00014 * 00015 * 00016 */ 00017 // ------------------------------------------------------------- 00018 00019 #ifndef _se_app_module_h_ 00020 #define _se_app_module_h_ 00021 00022 #include "boost/smart_ptr/shared_ptr.hpp" 00023 #include "se_factory_module.hpp" 00024 00025 namespace gridpack { 00026 namespace state_estimation { 00027 00028 // Calling program for state estimation application 00029 // Calling program for state estimation application 00030 class SEAppModule 00031 { 00032 public: 00033 /** 00034 * Basic constructor 00035 */ 00036 //SEAppModule(gridpack::parallel::Communicator comm); 00037 SEAppModule(void); 00038 00039 /** 00040 * Basic destructor 00041 */ 00042 ~SEAppModule(void); 00043 00044 /** 00045 * Get list of measurements from external file 00046 * @param cursor pointer to contingencies in input deck 00047 * @return vector of measurements 00048 */ 00049 std::vector<gridpack::state_estimation::Measurement> getMeasurements( 00050 gridpack::utility::Configuration::ChildCursors measurements); 00051 00052 /** 00053 * Read in and partition the network. The input file is read 00054 * directly from the state_estimation block in the configuration file so no 00055 * external file names or parameters need to be passed to this routine 00056 * @param network pointer to a SENetwork object. This should not have any 00057 * buses or branches defined on it. 00058 * @param config pointer to open configuration file 00059 */ 00060 void readNetwork(boost::shared_ptr<SENetwork> &network, 00061 gridpack::utility::Configuration *config); 00062 00063 /** 00064 * Assume that SENetwork already exists and just cache an internal pointer 00065 * to it. This routine does not call the partition function. Also read in 00066 * simulation parameters from configuration file 00067 * @param network pointer to a complete SENetwork object. 00068 * @param config pointer to open configuration file 00069 */ 00070 void setNetwork(boost::shared_ptr<SENetwork> &network, 00071 gridpack::utility::Configuration *config); 00072 00073 /** 00074 * Read branch and bus measurements. These will come from a separate file. 00075 * The name of this file comes from the input configuration file. 00076 */ 00077 void readMeasurements(void); 00078 00079 /** 00080 * Set up exchange buffers and other internal parameters and initialize 00081 * network components using data from data collection 00082 */ 00083 void initialize(); 00084 00085 /** 00086 * Solve the state estimation problem 00087 */ 00088 void solve(); 00089 00090 /** 00091 * Write final results of state estimation calculation to standard output 00092 */ 00093 void write(); 00094 00095 /** 00096 * Save results of state estimation calculation to data collection objects 00097 */ 00098 void saveData(); 00099 00100 private: 00101 00102 // pointer to network 00103 boost::shared_ptr<SENetwork> p_network; 00104 00105 // communicator for network 00106 gridpack::parallel::Communicator p_comm; 00107 00108 // pointer to factory 00109 boost::shared_ptr<SEFactoryModule> p_factory; 00110 00111 // pointer to bus IO module 00112 boost::shared_ptr<gridpack::serial_io::SerialBusIO<SENetwork> > 00113 p_busIO; 00114 00115 // pointer to branch IO module 00116 boost::shared_ptr<gridpack::serial_io::SerialBranchIO<SENetwork> > 00117 p_branchIO; 00118 00119 // pointer to configuration module 00120 gridpack::utility::Configuration *p_config; 00121 00122 // maximum number of iterations 00123 int p_max_iteration; 00124 00125 // convergence tolerance 00126 double p_tolerance; 00127 }; 00128 00129 } // state estimation 00130 } // gridpack 00131 #endif